package com.fjwt.gz.service.activity.platform.acte017;

import com.fjwt.gz.db.dto.ActivityAwardDTO;
import com.fjwt.gz.db.entity.SysExportTaskEntity;
import com.fjwt.gz.db.vo.StatActe017RecordVO;
import com.fjwt.gz.service.activity.AbstractExportReport;
import com.fjwt.gz.service.impl.StatActe017RecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * ------ 越减越便宜用户参与活动记录明细导出
 * @author myf
 */
@Slf4j
@Service
public class FansParticipationRecordExportReport extends AbstractExportReport<StatActe017RecordVO> {


    @Autowired
    private StatActe017RecordService statActe017RecordService;


    private static final Map<String, String> HEADER_ALIAS_MAP = new HashMap<>();
    static {
        HEADER_ALIAS_MAP.put("fansId", "用户唯一ID");
        HEADER_ALIAS_MAP.put("cstmName", "参与客户姓名");
        HEADER_ALIAS_MAP.put("phone", "参与客户手机号");
        HEADER_ALIAS_MAP.put("firstJoinTime", "参与时间");
        HEADER_ALIAS_MAP.put("firstWriteTime", "核销时间");
        HEADER_ALIAS_MAP.put("state", "卡券状态");
        HEADER_ALIAS_MAP.put("firstChannelCode", "入链账户");
        HEADER_ALIAS_MAP.put("firstChannelName", "入链账户名称");
        HEADER_ALIAS_MAP.put("channelAgentNo", "入链账户所属网点机构号");
        HEADER_ALIAS_MAP.put("b1SendNum", "B1券参与次数（激活）");
        HEADER_ALIAS_MAP.put("b2GetNum", "B2福分参与次数");
        HEADER_ALIAS_MAP.put("b3GetNum", "B3券参与次数（激活）");
        HEADER_ALIAS_MAP.put("cGetNum", "C券参与次数（激活）");
        HEADER_ALIAS_MAP.put("dGetNum", "D券参与次数（激活）");
        HEADER_ALIAS_MAP.put("isSuccess", "客户是否提升成功");
        HEADER_ALIAS_MAP.put("isAuth", "是否实名");
        HEADER_ALIAS_MAP.put("takePartIsAuth", "客户参与时是否完成实名认证");
    }


    @Override
    public String exportActivityExcel(SysExportTaskEntity sysExportTaskEntity) {
        ActivityAwardDTO activityAwardDTO = getRequestParam(sysExportTaskEntity.getRequestParam(), ActivityAwardDTO.class);
        List<StatActe017RecordVO> fansRecordList = statActe017RecordService.getBaseMapper().getFansRecord(activityAwardDTO);
        return createExcelAndUploadOssUrl(fansRecordList, HEADER_ALIAS_MAP, sysExportTaskEntity);
    }
}
